package com.saxon.blog.service.user;


import com.saxon.blog.Dao.User.UserDao;
import com.saxon.blog.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    private UserDao userDao;

    @Autowired
    @Qualifier ("userDao")
    public void setUserDao (UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public User getUserById (int id) {
        return userDao.getUserById (id);
    }

    @Override
    public int queryNum () {
        return userDao.queryNum ();
    }

    @Override
    public User getUser (Map<String, Object> map) {
        return userDao.getUser (map);
    }

    @Override
    public int insertUser (User user) {
        return userDao.insertUser (user);
    }

    @Override
    public int updateUser (String userAccount, String userPassword) {
        Map<String, Object> map = new HashMap<> ();
        map.put ("userAccount", userAccount);
        map.put ("userPassword", userPassword);
        map.put ("modifyDate", new Date ());
        return userDao.updateUser (map);
    }

    @Override
    public int updateUser (Map<String, Object> map) {
        return userDao.updateUser (map);
    }

    @Override
    public List<User> getUserWithList (Map<String, Object> map) {
        return userDao.getUserWithList (map);
    }

    @Override
    public int deleteUserById (Map<String, Object> map) {
        return userDao.deleteUserById (map);
    }
}
